﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;


[System.Serializable]
public class Story
{
    public int id_story;
    public List<ShortStory> shortStory;

    public List<string> id_charactor;
    public Dictionary<string, StoryCharacterData> charactorData;

    public void Instantiate(int i, List<ShortStory> list)
    {
        id_story = i;
        shortStory = list;
        getIdCharactor();
        creatCharactorData();
    }

    //将每一句对话中出现的角色的编号统一放在列表中
    public void getIdCharactor()
    {
        id_charactor = new List<string>();

        HashSet<string> id_ch = new HashSet<string>();
        foreach (var v in shortStory)
        {
            string[] order = v.order_character;

            id_ch.Add(order[0]);
            id_ch.Add(order[1]);
            id_ch.Add(order[2]);
        }
        foreach (var v in id_ch)
        {
            id_charactor.Add(v);
        }
    }

    //为每一句对话附上编号（目前没啥用）
    public void setShortStoryId()
    {
        int i = 0;
        foreach (var v in shortStory)
        {
            v.id_shortStory = i.ToString();
            i++;
        }
    }

    //创建人物信息列表（目前功能残缺）
    public void creatCharactorData()
    {
        charactorData = new Dictionary<string, StoryCharacterData>();
        foreach (var v in id_charactor)
        {
            StoryCharacterData scd = new StoryCharacterData();
            scd.creatStoryCharactorData(v);
            string id = scd.id_character;
            charactorData.Add(id, scd);
        }
    }
}
